package pojo;

import java.util.List;

/**
 * @author zhangyu
 * @date 2021/11/22    18:58
 */
public class PageBean<T> {
    private int currentPage ;
    private int pageSize ;
    private int totalCount ;
    private int totalPage ;
    private List<T> list ;

    public PageBean() {
    }
    public PageBean(int currentPage, int pageSize, int totalCount,  List<T> list) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.totalCount = totalCount;
        this.list = list;
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }

    /**
     * 总页数可以计算出来的
     * @return
     */
    public int getTotalPage() {
        // return (int) Math.ceil(totalCount/pageSize);
        return ((totalCount%pageSize==0)?totalCount/pageSize:totalCount/pageSize+1) ;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    @Override
    public String toString() {
        return "PageBean{" +
                "currentPage=" + currentPage +
                ", pageSize=" + pageSize +
                ", totalCount=" + totalCount +
                ", totalPage=" + totalPage +
                ", list=" + list +
                '}';
    }
}